
//------------------------------------------------------------------------------

using Apps.Models;
using Apps.IDAL.CY;
using System;
using System.Linq;

namespace Apps.DAL.CY
{
    public partial class CY_OUTSTOCK_DETAILRepository : BaseRepository<CY_OUTSTOCK_DETAIL>, ICY_OUTSTOCK_DETAILRepository, IDisposable
    {
        public CY_OUTSTOCK_DETAILRepository(DBContainer db) : base(db)
        {

        }

        public IQueryable<CY_OUTSTOCK_DETAILModel> QueryOutStockDetailList()
        {
            var result = from a in Context.CY_OUTSTOCK_DETAIL
                         join b in Context.V_PUB_CY_STOCKPILE on a.STOCKPILE_ID equals b.STOCKPILE_ID into tbs
                         from tb in tbs.DefaultIfEmpty()
                         select new CY_OUTSTOCK_DETAILModel()
                         {
                             CALC_TIME = a.CALC_TIME,
                             COALYARD_AMOUNT = a.COALYARD_AMOUNT,
                             DETAI_ID = a.DETAI_ID,
                             IS_CALC = a.IS_CALC,
                             OUTSTOCK_ID = a.OUTSTOCK_ID,
                             PARTITION_ID = tb.PARTITION_ID,
                             PARTITION_NAME = tb.PARTITION_NAME,
                             START_AMOUNT = a.START_AMOUNT,
                             STOCKPILE_ID = a.STOCKPILE_ID,
                             STOCKPILE_NAME = tb.STOCKPILE_NAME,
                             TARGET_BOILER = a.TARGET_BOILER
                         };

            return result;

        }
    }
}
